/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.edu.nju.software.login.action;

import cn.edu.nju.software.login.domain.User;
import cn.edu.nju.software.login.factory.ServiceFactory;
import cn.edu.nju.software.login.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 *
 * @author han
 */
public class UserAction extends ActionSupport {
    private String username;

    private String password;
    
    public String execute(){
System.out.println("fejawoigjero");
        return SUCCESS;
    }
   
    public String login(){
        UserService us = ServiceFactory.getUserServiceInstance();
        boolean success = us.isLogin(username, password);
        if(success){
            return SUCCESS;
        }else{
            return "Wrong";
        }
    }
    
    public String add(){
        UserService us = ServiceFactory.getUserServiceInstance();
        User user = new User();
        user.setPassword(password);
        user.setUserName(username);
        us.addUser(user);
        return SUCCESS;
    }
    
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
